package com.auth.manage.controller.admin;

import com.auth.manage.domain.service.AuthorizationService;
import com.auth.manage.param.admin.AddOrDeductPortLimitParam;
import com.auth.manage.web.vo.Result;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RequiredArgsConstructor
@RestController
@RequestMapping("/admin/authCodes")
public class AdminAuthorizationController {

    private final AuthorizationService authorizationService;

    // 添加端口上限
    @PostMapping("addPortLimit")
    public Result addPortLimit(@RequestBody @Validated AddOrDeductPortLimitParam param){
        authorizationService.addPortLimit(param.getAuthCodeId(), param.getCount());
        return Result.success();
    }

    // 减少端口上限：
    @PutMapping("deductPortLimit")
    public Result deductPortLimit(@RequestBody @Validated AddOrDeductPortLimitParam param){
        authorizationService.deductPortLimit(param.getAuthCodeId(), param.getCount());
        return Result.success();
    }
}
